{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "09244bc2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请在接下来的输入中提供 4 个数（可空格分隔），可以分多行输入，输入足够数量后程序将计算并输出结果。\n",
      "5.00\n",
      "5.00\n"
     ]
    }
   ],
   "source": [
    "def main():\n",
    "    try:\n",
    "        n_line = input(\"请输入整数 N: \").strip()\n",
    "    except EOFError:\n",
    "        print(\"未检测到输入，退出\")\n",
    "        return\n",
    "    if not n_line:\n",
    "        print(\"未输入 N，退出\")\n",
    "        return\n",
    "    try:\n",
    "        n = int(n_line)\n",
    "    except Exception as e:\n",
    "        print(\"无效的 N：\", e)\n",
    "        return\n",
    "    nums = []\n",
    "    print(f\"请在接下来的输入中提供 {n} 个数（可空格分隔），可以分多行输入，输入足够数量后程序将计算并输出结果。\")\n",
    "    while len(nums) < n:\n",
    "        try:\n",
    "            line = input().strip()\n",
    "        except EOFError:\n",
    "            break\n",
    "        if not line:\n",
    "            continue\n",
    "        try:\n",
    "            parts = list(map(float, line.split()))\n",
    "        except Exception as e:\n",
    "            print(\"解析输入为浮点数失败：\", e)\n",
    "            continue\n",
    "        nums.extend(parts)\n",
    "    if len(nums) < n:\n",
    "        print(\"输入数量不足，已读取\", len(nums), \"个数，退出\")\n",
    "        return\n",
    "    nums = nums[:n]\n",
    "    total = 0.0\n",
    "    for i, v in enumerate(nums):\n",
    "        total += v * (i+1) * (n - i)\n",
    "    print(f\"{total:.2f}\")                                                      \n",
    "\n",
    "if __name__ == \"__main__\":\n",
    "    main()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "py39",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.23"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
